

#ifndef _STRING_UTILS_H
#define _STRING_UTILS_H


#include "common.h"
#include <sys/types.h>

#ifndef STR
	#define STR(x)		#x
#endif


/*-----------------------------------------------------------------------------------------
 * Function: Convert lowercase letters to uppercase letters.
 *
 * Parameter:
 *    <str>: 	[IN] point to the target string.
 *    <maxLen>: [IN] the max length you want to convert from the beginning of target string.
 *
 * Return:
 *    NULL: when exection error occurs.
 *    The pointer to the converted string.
-----------------------------------------------------------------------------------------*/
extern char * 	str2upper(char * str, uint32 maxLen);



/*-----------------------------------------------------------------------------------------
 * Function: Convert uppercase letters to lowercase letters.
 *
 * Parameter:
 *    <str>: 	[IN] point to the target string.
 *    <maxLen>: [IN] the max length you want to convert from the beginning of target string.
 *
 * Return:
 *    NULL: when exection error occurs.
 *    The pointer to the converted string.
-----------------------------------------------------------------------------------------*/
extern char * 	str2lower(char * str, uint32 maxLen);



/*-----------------------------------------------------------------------------------------
 * Function: Convert the decimal string to 32 bits integer.
 *
 * Parameter:
 *    <str>: 		[IN] 	point to the target string.
 *    <maxLen>: 	[IN] 	the max length you want to convert from the beginning of target string.
 *    <intgr_ptr>:	[OUT]	point to the converted result.
 *
 * Return:
 *    TRUE: 	convert successfully.
 *    FALSE:	convert failed.
 *
 * Note:
 *    1. We support the negative decimal string converting.
 *    2. We most take the first TEN continuous decimal characters for converting,
 *       cause that the maximal value of int-type is 2147483647.
 *    3. You can set the value of <maxLen> greater than the target string length, we take the smaller one
-----------------------------------------------------------------------------------------*/
extern bool 	str2int32(char * str, uint32 maxLen, int * intgr_ptr);



/*-----------------------------------------------------------------------------------------
 * Function: Convert the hexadecimal string to 32 bits integer.
 *
 * Parameter:
 *    <str>: 		[IN] 	point to the target string.
 *    <maxLen>: 	[IN] 	the max length you want to convert from the beginning of target string.
 *    <intgr_ptr>:	[OUT]	point to the converted result.
 *
 * Return:
 *    TRUE: 	convert successfully.
 *    FALSE:	convert failed.
 *
 * Note:
 *    1. We most take the first EIGTH continuous hexadecimal characters for converting,
 *       cause that the maximal value of int-type is FFFFFFFF.
 *    2. You can set the value of <maxLen> greater than the target string length, we take the smaller one
-----------------------------------------------------------------------------------------*/
extern bool 	hexstr2int32(char * str, uint32 maxLen, int * intgr_ptr);



/*-----------------------------------------------------------------------------------------
 * Function: Convert the hexadecimal string to 64 bits integer.
 *
 * Parameter:
 *    <str>: 		[IN] 	point to the target string.
 *    <maxLen>: 	[IN] 	the max length you want to convert from the beginning of target string.
 *    <intgr_ptr>:	[OUT]	point to the converted result.
 *
 * Return:
 *    TRUE: 	convert successfully.
 *    FALSE:	convert failed.
 *
 * Note:
 *    1. We most take the first SIXTEEN continuous hexadecimal characters for converting,
 *       cause that the maximal value of int64-type is 0xFFFFFFFFFFFFFFFF.
 *    2. You can set the value of <maxLen> greater than the target string length, we take the smaller one
-----------------------------------------------------------------------------------------*/
extern bool 	hexstr2int64(char * str, uint32 maxLen, int64 * intgr_ptr);

extern char * 	data2CString( const uint8_t *inBuf, size_t inBufLen );

#endif

